<template>
  <!-- element-ui 级联组件 -->
  <el-cascader size="mini" :options="treeData" :props="props" separator="-" />
</template>
<script>
import { getDepartment } from '@/api/department'
import { transListToTreeData } from '@/utils'
export default {
  data() {
    return {
      treeData: [], // 赋值给 级联组件的options
      props: {
        label: 'name',
        value: 'id'
      }
    }
  },
  created() {
    this.getDepartment()
  },
  methods: {
    async getDepartment() {
      const result = await getDepartment()
      const data = transListToTreeData(result, 0)
      this.treeData = data
    }
  }
}
</script>
